<!DOCTYPE html>
<html>
<head>
    <title>声撩召集令</title>
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <meta charset="utf-8">

    <link rel="stylesheet" type="text/css" href="static/aui.css">
    <link rel="stylesheet" type="text/css" href="static/reg.css">
</head>

<body style="height: 56rem;">
<div class="back_all_img">
</div>

<div class="my_invite_img">
</div>


<div class="alert_block div_main" id="alert_block">
    <div class="alert_main_border">
        <div class="alert_main">

            <div class="text_h4">亲爱的玩家：</div>
            <div class="text_h4">本次活动期间您共召集好友<span id="all_count">0</span>人，其中充值好友<span id="money_user_count"></span>人
            </div>

            <table class="table table_data">
                <tr>
                    <th>ID</th>
                    <th>昵称</th>
                    <th>注册时间</th>
                </tr>
            </table>
        </div>
    </div>
</div>

<a class="footer_menus">
    <img onClick="testClick1()" src="static/images/create_link.png">
</a>

<div class="alert_all_bg"></div>
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
<script src="./static/event-util.js.js"></script>
<script
    type="text/javascript"> document.write('<script type="text/javascript" src="static/pub.js?time=' + new Date().getTime() + '"><' + '/' + 'script>');</script>


<script type="text/javascript">
    //	var shareUrl = "http://" +document.domain +":5083";

    $(function () {
        var top = ($(window).height() - $('.alert_block').outerHeight()) / 2 + $(document).scrollTop();
        $('.alert_block').css({
            'top': top + 'px',
        })

        $('.alert_all_bg').click(function () {
            $("table").html("");
            $('.alert_block').fadeOut();
            $('.alert_all_bg').fadeOut();
        })

    })
    var user_id = getUrlParam('user_id')

    $(document).ready(function () {
        var user_id = getUrlParam('user_id')

        $.ajax({
            url: shareUrl + "/invite/getShareConfig",//要请求的服务器url
            data: {
                user_id: user_id,
            },
            type: "POST", //请求方式为POST
            dataType: "json",   //服务器返回的数据是什么类型
            success: function (result) {  //这个方法会在服务器执行成功是被调用 ，参数result就是服务器返回的值(现在是json类型)
                if (result.code == 0) {
                    $("#share_date").html(result.data.share_date)
                } else {

                }
            }
        });
    });


    $('.my_invite_img').click(function () {

        $.ajax({
            url: shareUrl + "/invite/inviteUser",//要请求的服务器url
            data: {
                user_id: user_id,
            },
            type: "POST", //请求方式为POST
            dataType: "json",   //服务器返回的数据是什么类型
            success: function (result) {  //这个方法会在服务器执行成功是被调用 ，参数result就是服务器返回的值(现在是json类型)
                if (result.code == 0) {
                    var data = result.data;
                    $("#all_count").text(data.all_count);
                    $("#money_user_count").text(data.money_user_count);
                    var res = data.user_info;
                    var tempHtml = "";
                    for (var i = 0; i < res.length; i++) {
                        tempHtml += "<tr><td>" + res[i]["uuid"] + "</td>";
                        tempHtml += "<td>" + res[i]["nickname"] + "</td>";
                        tempHtml += "<td>" + res[i]["create_time"] + "</td></tr>";
                    }
                    $("table").append(tempHtml); //添加你拼接好的html到table里
                } else {
                }
            }
        });
        $('.alert_block').fadeIn();
        $('.alert_all_bg').fadeIn();
    })

    var url = shareUrl + '/wx_html/shares.html?user_id=' + user_id;//分享注册url

    var isIOS = function () {
        return !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
    }
    var isAndroid = function () {
        return navigator.userAgent.indexOf('Android') > -1 || navigator.userAgent.indexOf('Linux') > -1;
    }

    function testClick1() {

        let u = navigator.userAgent;
        var equipmentType = "";
        var agent = navigator.userAgent.toLowerCase();
        var android = agent.indexOf("android");

        // var android = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; /*android终端或者uc浏览器*/
        var iphone = agent.indexOf("iphone");
        var ipad = agent.indexOf("ipad");
        var img = '';
        /*获取分享配置信息及用户头像*/
        $.ajax({
            url: shareUrl + "/invite/getShareConfig",//要请求的服务器url
            data: {
                user_id: user_id,
            },
            type: "POST", //请求方式为POST
            dataType: "json",   //服务器返回的数据是什么类型
            success: function (result) {  //这个方法会在服务器执行成功是被调用 ，参数result就是服务器返回的值(现在是json类型)
                console.log(result)
                if (result.code == 0) {
                    var img = result.data.u_img;
                    var title = result.data.title;
                    var desc = result.data.desc;

                    if (isIOS()) {
                        var data = {"url": url, "image": img, "desc": desc, "title": title}
                        window.webkit.messageHandlers.shareClicked.postMessage(data);
                    } else if (isAndroid()) {
                        keke.shareClicked(url + '', img + '', desc + '', title + '');
                    }
                    // if (android != -1) {
                    //     alert('android')
                    //     test.shareClicked('1', '2', '2', '2');
                    // }
                    // if (iphone != -1 || ipad != -1) {
                    //     alert('ios');
                    //     var data = {"url": url, "image": img, "desc": desc, "title": title}
                    //     window.webkit.messageHandlers.shareClicked.postMessage(data);
                    // }
                } else {
                    if (android != -1) {
                        test.shareClicked(url, './', '壳壳语音分享邀请链接', '壳壳邀请链接');
                    }
                    if (iphone != -1 || ipad != -1) {
                        var data = {"url": url, "image": './', "desc": "壳壳语音分享邀请链接", "title": "壳壳邀请链接"}
                        window.webkit.messageHandlers.shareClicked.postMessage(data);
                    }
                }
            }
        });


    }


    //		window.webkit.messageHandlers.shareClicked.postMessage( url,'./','壳壳语音分享邀请链接','邀请链接');

    function getUrlParam(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
        var r = window.location.search.substr(1).match(reg);  //匹配目标参数
        if (r != null) return unescape(r[2]);
        return null; //返回参数值
    }

</script>

</body>
</html>
